﻿@{
    ViewBag.Title = "Index";
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>卒中病历</title>
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/ligerui-icons.css" />
    <link rel="stylesheet" href="~/Scripts/ligerUI/skins/Gray/css/all.css" />
    <link rel="stylesheet" href="~/Content/css/common.css" />
    <link rel="stylesheet" href="~/Scripts/laydate/theme/default/laydate.css" />
    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Scripts/jquery.form.js"></script>
    <script src="~/Scripts/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script type="text/javascript">
        var defaultSelpId = "@ViewBag.patientId";
        var review = @ViewBag.Review;
        $(document).ready(function () {
            waitting1 = $.ligerDialog.waitting('加载中，请稍候...');
            $.ajax({
                url: "/StrokeCenter/FirstAid/GetPatientList", cache: false, success: function (data) {
                    var d = $.parseJSON(data);
                    if (d.Result == 1) {
                        var jsonData = $.parseJSON(d.Body);
                        $("#selPatientList").html('');
                        for (var i = 0; i < jsonData.length; i++) {
                            var htmlselected = defaultSelpId == jsonData[i].PATIENT_ID ? "selected=\"selected\"" : "";
                            $("#selPatientList").append("<option " + htmlselected + " value=" + jsonData[i].PATIENT_ID + ">" + jsonData[i].PATIENT_NAME + "&nbsp;&nbsp;&nbsp;" + (jsonData[i].PATIENT_SEX == 1 ? "男" : jsonData[i].PATIENT_SEX == 0 ? "女" : jsonData[i].PATIENT_SEX) + "&nbsp;&nbsp;&nbsp;" + (IsEmpty(jsonData[i].PATIENT_AGE) ? "" : jsonData[i].PATIENT_AGE + "岁") + "</option>");
                        }                        
                    }
                    selectPatient();
                    waitting1.close();
                },
                error: function () {
                    waitting1.close();
                    $.ligerDialog.error("程序错误");
                }
            });
            $(document).on("click", ".closeCls", function () {
                window.location.reload(true);
            });
        })
        function selectPatient() {
            if ($("#selPatientList").val() != null) {
                //获取卒中诊断类型 再跳转
                $.post("/StrokeCenter/MedicalRecords/GetStrokeDiagnosis", { txtID: $("#selPatientList").val() }, function (data, textStatus) {
                    if (textStatus == "success") {
                        var d = $.parseJSON(data);
                        if (d.Result == 1) {
                            var res = IsEmpty(d.Body) ? "" : parseInt(d.Body);
                            $("#p-1,#p0,#p1,#p2,#p3").hide();
                            $("#p" + res).show();
                            var url = $("#p" + res + " a").attr("href");
                            if (typeof (url) != "undefined") {
                                if (url.indexOf("?") > 0)
                                    url = url.split("?")[0];
                                url += "?pid=" + $("#selPatientList").val();
                                if (defaultSelpId != "")
                                    if(review != 0)url += "&review="+review;
                                    location.replace(url);
                                $("#p" + res + " a").attr("href", url);
                            }                           
                        }
                        else if (d.Result == 0) {
                            $.ligerDialog.error(d.Body);
                        }
                        else {
                            $.ligerDialog.error("程序错误");
                            $("#p-1,#p0,#p1,#p2,#p3").hide();
                            $("#p" + -1).show();
                        }
                    }
                });
            }
        }
        function edit() {
            var id = $("#selPatientList").val();
            if (id == null) id = 0;
            var tit = parseInt(id) > 0 ? "编辑患者" : "新增患者";
            $.ligerDialog.open({
                height: 400,
                width: 520,
                title: tit,
                url: '/StrokeCenter/PatientList/Edit?Id=' + id,
                showMax: false,
                showToggle: false,
                showMin: false,
                isResize: false,
                slide: false,
                data: {},
                buttons: [{
                    text: '回调函数', onclick: function (i, d) {
                        window.location.reload(true);
                    }
                }],
                cls: "closeCls"
            }).max();
            $(".l-dialog-buttons").hide();
        }
        function baseInforEdit() {
            window.location.href = "/StrokeCenter/MedicalRecords/Commonmr?pid=" + $("#selPatientList").val();
        }
    </script>
</head>
<body>
    <div style="font-size: 13px; width: 100%; height:80px; background-color: #f1f6f8;">
        <div style="float:left; margin-left:20px; margin-top:40px;">
            选择患者：<select style="width:150px;" id="selPatientList" name="selPatientList" onchange="selectPatient();"></select>
        </div>
    </div>
    <div style="font-size: 13px; width: 100%; height: 40px; background-color: #f1f6f8;">
        <p id="p-1" style="margin-left:25px;"><a style="cursor:pointer;" onclick="edit(); return false;">未知的卒中诊断类型，请在此修改</a><br /><a style="cursor:pointer;" onclick="baseInforEdit(); return false;">未知的卒中诊断类型，基础病历</a></p>
        <p id="p0" style="margin-left:25px;"><a href="/StrokeCenter/MedicalRecords/Ceacasmr">病历：CEA 、 CAS</a></p>
        <p id="p1" style="margin-left:25px;"><a href="/StrokeCenter/MedicalRecords/Jmrsxgnjrzlmr">病历：静脉溶栓、血管内介入治疗</a></p>
        <p id="p2" style="margin-left:25px;"><a href="/StrokeCenter/MedicalRecords/Ncxmr">病历：脑出血</a></p>
        <p id="p3" style="margin-left:25px;"><a href="/StrokeCenter/MedicalRecords/Lndmlmr">病历：颅内动脉瘤</a></p>
    </div>
</body>
</html>